<?php
/**
 * <OXmlAttribute>
 *  Copyright (C) <2011>  <Omar Teodoro Alegre>
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
 * ********************************************************
 * ********************************************************
 *                    OXmlAttribute
 * ********************************************************
 * ********************************************************
 * 
 * @version 1.0
 * @created 28-ago-2011 07:07:53 p.m.
 * @author Omar Teodoro Alegre - alegreomarteodoro@yahoo.com.ar
 *  Corrientes, Argentina.
 */

class OXmlAttribute
{

	protected $_parent_element;
	protected $_value;
	protected $_name;

	/** Constructor */
	
	public function __construct( $name , $value = NULL )
	{
		$this->setName( $name );
        $this->setValue( $value );
	}

	/** Setters and Getters */
	
	/**
	 * Devuelve el elemento padre.
	 * @return OXmlElement - Elemento pabre.
	 */
	public function getParentElement()
	{
		return $this->_parent_element;
	}

	/**
	 * Devuelve el valor actual del atriburo.
	 */	
	public function getValue()
	{
		return $this->_value;
	}
	
	/**
	 * Devuelve el nombre del atributo.
	 * @return String - Nombre del atributo.
	 */
	public function getName()
	{
		return $this->_name;
	}

	/**
	 * Define el elemento padre.
	 * @param OXmlElement parent_element - Elemento padre.
	 */
	public function setParentElement( OXmlElement $parent_element)
	{
		$this->_parent_element = $parent_element;
	}

	/**
	 * Define el valor del atributo.
	 * @param value - Valor de atributo (String o Number).
	 */
	public function setValue($value)
	{
		$this->_value = $value;
	}
	
	/**
	 * Define el nombre del atributo.
	 * @param String name - Nombre del atributo.
	 */
	public function setName($name)
	{
		$this->_name = OXmlValidator::checkName( $name );
	}
	
	/** Metodos */

	/**
	 * Devuelve una cadena con el atributo en formato xml.
	 */
	public function toString()
	{
		return $this->getName() . '="' . $this->getValue() . '"';
	}
}
?>